package com.sanben.demand.service.impl;

import com.sanben.demand.entity.CommentReply;
import com.sanben.demand.mapper.CommentReplyMapper;
import com.sanben.demand.service.ICommentReplyService;
import com.sanben.demand.data.dto.CommentReplyDto;
import com.sanben.demand.data.vo.CommentReplyVo;
import com.sanben.demand.data.req.CommentReplyReq;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sanben.common.util.BeanCopyUtils;
import java.util.List;

/**
 * @author cyh
 * @description: comment_reply 评论回复表 服务实现类
 * @date: 2020-08-18
 */
@Service
public class CommentReplyServiceImpl extends ServiceImpl<CommentReplyMapper,CommentReply> implements ICommentReplyService {

    @Override
    public IPage<CommentReplyVo> page(CommentReplyReq req) {
        Page<CommentReplyVo> page = new Page<>(req.getPageNum(), req.getPageSize());
        page.setRecords(this.baseMapper.page(page, req));
        return page;
    }

    @Override
    public List<CommentReply> lists() {
        return this.list();
    }

    @Override
    public Boolean save(CommentReplyDto dto) {
        return this.save(BeanCopyUtils.copy(dto,CommentReply.class));
    }

    @Override
    public Boolean updateById(CommentReplyDto dto) {
        return this.updateById(BeanCopyUtils.copy(dto,CommentReply.class));
    }


    @Override
    public Boolean deleteLogic(List<Integer> toIntList) {
        return  this.removeByIds(toIntList);
    }

    @Override
    public CommentReply detail(Integer id) {
        return this.getById(id);
    }
}
